<?php

namespace App\Admin\Actions\Tools\User;

use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\Tools\AbstractTool;
use Dcat\Admin\Traits\HasPermissions;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class CreateAgent extends AbstractTool
{
    /**
     * @return string
     */
    protected $title = '创建代理';

    /**
     * 按钮样式定义，默认 btn btn-white waves-effect
     *
     * @var string
     */
    protected $style = 'btn btn-primary btn-mini btn-outline';


    /**
     * Handle the action request.
     *
     * @param Request $request
     *
     * @return Response
     */
    public function handle(Request $request)
    {

    }

    /**
     * @return string|void
     */
    protected function href()
    {
    }

    /**
     * @return string|array|void
     */
    public function confirm()
    {
        return [];
    }

    /**
     * @param Model|Authenticatable|HasPermissions|null $user
     *
     * @return bool
     */
    protected function authorize($user): bool
    {
        return true;
    }

    /**
     * @return array
     */
    protected function parameters()
    {
        return [];
    }

    public function render()
    {
        // 实例化表单类并传递自定义参数
        $form = \App\Admin\Forms\User\CreateAgentForm::make()->payload([]);
        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->button("<button class='btn btn-primary btn-mini btn-outline'>{$this->title}</button>");
    }
}
